



/* Difference-in-difference estimates  */

 

clear all

cd "G:\Data\Workdata\707677\FKYY7677\Debt_relief\Statafiles\Outputs\Revision\FINAL"

use "G:\Data\Workdata\707677\Common\01Data\02STATA\panel_iv"



sort pnr aar





/* Local macro for list of covariates */

local cov "yeardum2-yeardum40"





/* Local macro for selection of observations */


local selection "time>-5 & time<17 & sumpre>0 & sumpost>0"




/* Create covariates for regressions */



tab aar, gen(yeardum)											/* Year dummies */

tab time if (time>-5 & time<17), gen(timedum)					/* Time dummies */




/* Create variables for difference-in-difference setup */


gen treated=granted

gen after=0

replace after=1 if time>0

gen interaction=treated*after






/* IV Regress */

destring pnr, replace

xtset pnr aar



/**************************************************************************/
/*                                                                        */
/* MAIN REGRESSION WITH RELATIVE TIME TO APPLICATION DUMMIES- UNWEIGHTED  */
/*                                                                        */
/**************************************************************************/




/*****************/
/* Earned income */
/*****************/


gen outcome=erhvervsindk_real


replace outcome=. if time<-4

replace outcome=. if time>16


gen pre=0

gen post=0

replace pre=1 if (outcome~=. & time<1)

replace post=1 if (outcome~=. & time>0)


by pnr: egen sumpre=sum(pre)

by pnr: egen sumpost=sum(post)



xtreg outcome interaction timedum2-timedum21 `cov' if (`selection'), cluster(pnr) fe

outreg2 using did_fixedeffects.xls, replace ctitle(erhvervsindk_real)

outreg2 using did_fixedeffects_short.xls, replace ctitle(erhvervsindk_real) keep(interaction)


drop outcome pre post sumpre sumpost



/******************************************/
/* Loop over remaining outcome variables  */
/******************************************/


local depvar "employed_pstill unemployed_pstill out_of_lf_pstill timelon_real aktiv_real passiv_real formue_real koejd_real house tilbtot_real disability kontant_real social   mortgage_real bankgaeld_real"





foreach var of varlist `depvar'{



gen outcome=`var'


replace outcome=. if time<-4

replace outcome=. if time>16


gen pre=0

gen post=0

replace pre=1 if (outcome~=. & time<1)

replace post=1 if (outcome~=. & time>0)


by pnr: egen sumpre=sum(pre)

by pnr: egen sumpost=sum(post)



xtreg outcome interaction timedum2-timedum21 `cov' if (`selection'), cluster(pnr) fe

outreg2 using did_fixedeffects.xls, append ctitle(`var')

outreg2 using did_fixedeffects_short.xls, append ctitle(`var') keep(interaction)


drop outcome pre post sumpre sumpost




}

